package com.sync.syncmasterdata;


import com.sync.syncmasterdata.outsystem.entity.CrmContactErpAnmEntity;
import com.sync.syncmasterdata.outsystem.entity.CusDeliverAddErpAnmEntity;
import com.sync.syncmasterdata.outsystem.entitymbt.CrmContactErpMBTEntity;
import com.sync.syncmasterdata.outsystem.entitymbt.CusDeliverAddErpMBTEntity;
import com.sync.syncmasterdata.outsystem.service.CustomerAddAndContactService;
import com.sync.syncmasterdata.util.NormalUtil;
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import java.util.UUID;


@SpringBootTest
@Slf4j
class SyncMasterDataApplicationTestsOutSystem {

    @Autowired
    private CustomerAddAndContactService customerAddAndContactService;

    @Test
    void contextLoads() {
    }

    @Test
    public void pushCustomerContact(){
        CrmContactErpMBTEntity entity = new CrmContactErpMBTEntity();
        entity.setDCreateDate(NormalUtil.getNowTime());
//        entity.setUfts(generateHexTimestamp());
        entity.setOID("{" + UUID.randomUUID().toString() + "}");
        entity.setCContactCode( String.valueOf(System.currentTimeMillis()));
        entity.setCCusCode("022201002");
        entity.setCContactName("张三");
        entity.setCMobilePhone("110");
        customerAddAndContactService.createCrmContractToU8(entity);

    }

    @Test
    public void pushCustomerAdd(){
        CusDeliverAddErpMBTEntity entity = new CusDeliverAddErpMBTEntity();
        entity.setBDefault(1);
        entity.setCAddCode(String.valueOf(System.currentTimeMillis()));
        entity.setCDeliverAdd("测试地址");
        entity.setCCusCode("022201002");
        entity.setCCusAddressGUID(UUID.randomUUID().toString().toUpperCase());
        customerAddAndContactService.createShippingAddressToU8(entity);
    }

    private String generateHexTimestamp() {
        long currentTimeMillis = System.currentTimeMillis();
        return String.format("0x%016X", currentTimeMillis);
    }


}
